﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using AMatysiak.Methods;

namespace AMatysiakTest.Methods.TypeExtensions
{
    [TestClass]
    public class ToDateTest
    {
        [TestMethod]
        public void parseCurrentDate()
        {
            string s = DateTime.Now.ToString();
            DateTime dt = s.ToDate();

            Assert.AreEqual(DateTime.Now.Date, dt);
        }

        [TestMethod]
        public void parseOnlyDate()
        {
            string s = "2010-10-12";
            DateTime dt = s.ToDate();
            DateTime expected = DateTime.Parse(s);

            Assert.AreEqual(expected, dt);
        }

        [TestMethod]
        [ExpectedException(typeof(FormatException))]
        public void wrongDate()
        {
            string s = "2010-13-13";
            s.ToDate();
        }
    }
}
